From 9e07f7e2e8a393edb9aa7a6010e576ec35f0495f Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 8 Feb 2023 16:46:10 -0800 Subject: invoice requests and btc deposits --- src/routes/(app)/[username]/invoice/[hash]/+layout.server.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/routes/(app)/[username]/invoice/[hash]/+layout.server.js') diff --git a/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js b/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js index 0f6168e3..b5323d3f 100644 --- a/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js +++ b/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js @@ -2,11 +2,16 @@ import Qr from 'qrcode-base64'; import { get } from '$lib/utils'; import { redirect } from '@sveltejs/kit'; -export async function load({ depends, params, url }) { +export async function load({ depends, params, url, parent }) { depends('app:invoice'); + let { user } = await parent(); let { hash } = params; let invoice = await get(`/invoice/${hash}`); + + if (user && invoice.uid !== user.id && !url.pathname.includes('tip')) + throw redirect(307, `/send/invoice/${hash}`); + let { amount, received } = invoice; amount = parseInt(amount); -- cgit v1.2.3